package com.tubi.maipiao4;

public class demo4 {
    public static void main(String[] args) {
        Object obj1 = new Object();
        Object obj2 = new Object();

        new Thread(()->{
            while (true){
                synchronized (obj1){
                    synchronized ((obj2)){
                        System.out.println("小抗同学");
                    }
                }
            }
        }).start();

        new Thread(()->{
            while (true){
                synchronized (obj2){
                    synchronized ((obj1)){
                        System.out.println("小未同学");
                    }
                }
            }
        }).start();
    }
}
